 IDENTIFICATION DIVISION.
 PROGRAM-ID. XRSREAL.
 AUTHOR. DENNIS OLENICK, OPT-TECH DATA PROCESSING.
***************************************************
 ENVIRONMENT DIVISION.
 CONFIGURATION SECTION.
 SOURCE-COMPUTER. IBM-PC.
 OBJECT-COMPUTER. IBM-PC.
 INPUT-OUTPUT SECTION.
 FILE-CONTROL.
     SELECT SAMPLE-DATA ASSIGN 'SAMP.DAT'.
     SELECT SCREEN-OUTPUT ASSIGN 'CON:'.
 DATA DIVISION.
 FILE SECTION.
 FD SAMPLE-DATA
     LABEL RECORDS ARE STANDARD.
 01  IO-AREA       PIC X(75).
 FD SCREEN-OUTPUT
     LABEL RECORDS ARE STANDARD.
 01  OUTPUT-AREA   PIC X(75).
 WORKING-STORAGE SECTION.	     
 01  FUNC          PIC 999 COMP-5.
 01  LEN           PIC 999 COMP-5.
 01  RET-CODE      PIC 999 COMP-5.
 01  RET-CODE-DISP PIC 9(5).
***************************************************
 PROCEDURE DIVISION.
 MAINLINE.
     OPEN INPUT SAMPLE-DATA.
     OPEN OUTPUT SCREEN-OUTPUT.
*SET UP FOR INITIALIZATION CALL FUNC=1 
 SET-UP. 
     MOVE 1 TO FUNC.
     MOVE 'S(1,10,C,A)' TO IO-AREA.
     MOVE 20 TO LEN.
     CALL 'RSREAL' USING  FUNC, IO-AREA, LEN, RET-CODE.
     IF RET-CODE NOT EQUAL 0 GO TO END-PGM.

*PASS RECORDS TO OPT-TECH SORT FUNC=2 
 PASS-RECORDS.
     MOVE 2 TO FUNC.
     READ SAMPLE-DATA RECORD AT END GO TO RECIEVE-RECORDS.
     MOVE 100 TO LEN.
     CALL 'RSREAL' USING  FUNC, IO-AREA, LEN, RET-CODE.
     IF RET-CODE NOT EQUAL 0 GO TO END-PGM.
 	   GO TO PASS-RECORDS.

*RECIEVE SORTED RECORDS BACK FUNC=3
 RECIEVE-RECORDS.
     MOVE 3 TO FUNC.
     CALL 'RSREAL' USING  FUNC, IO-AREA, LEN, RET-CODE.
     IF RET-CODE EQUAL 1 STOP RUN.
     IF RET-CODE NOT EQUAL 0 GO TO END-PGM.
     WRITE OUTPUT-AREA FROM IO-AREA.
     GO TO RECIEVE-RECORDS.

 END-PGM.
     MOVE RET-CODE TO RET-CODE-DISP.
     DISPLAY 'RET-CODE=', RET-CODE-DISP.
     STOP RUN.
